home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 / Ham Radio 2000.iso / ham2000 / misc / tasm / misc.zoo / sc11lib.asm < prev    next >
Assembly Source File  |  1990-12-26  |  6KB  |  334 lines

  1.  
  2. *********************************************************
  3. *
  4. *       c11lib --
  5. *               This file contains the run-time library
  6. *       routines used by the 6801 tiny-c compiler 'c01'.
  7. *       They should be appended onto the assembly code
  8. *       generated by 'c01' and the entire mess assembled
  9. *       to create a single load module.
  10. ***********************************************************
  11. *
  12. *       Modified for compatibility with TASM. tna 12/27/90
  13. *       TASM requires a semicolon at the beginning of all
  14. *       embedded comments.
  15. *
  16. ***********************************************************
  17. *
  18. *       ccdchx --  Code to fetch a character into secondary
  19. *            indirect from address in primary.
  20. *
  21. ccdchx  equ *
  22.         xgdx
  23.         clra
  24.         ldab    0,x     ; get character into b       */
  25.         bge     *+3
  26.         coma            ;  sign extend char into d   */
  27.         xgdx
  28.         rts
  29. *
  30. ******************
  31. *
  32. *       ccdnt --  Code to fetch a pointer or integer
  33. *           into primary indirect from address in primary.
  34. *
  35. ccdnt   equ *
  36.         xgdx            ; tfr addr from d to x */
  37.         ldd 0,x                ; Fetch int */
  38.         rts
  39. *********************************************
  40. *       ccmods -- Code to modify stack pointer (is in X).
  41. *
  42. ccmods  equ *
  43.  pshx           ; Add offset to stack ptr */
  44.  tsx
  45.  addd 0,x       ;add Dreg + Sreg
  46.  pulx
  47.  xgdx           ;answer to Xreg
  48.  rts
  49. *
  50.  
  51. *    ccswitch   D reg contains the switch value
  52. ccswit  pulx            ;get the return address (points to switch table)
  53. ccsw4   pshx
  54.         ldx     0,x     ;get label & check for
  55.         cpx     #0      ;end of switch table
  56.         beq     ccsw2
  57.         pulx
  58.         cpd     2,x     ;check for case value
  59.         bne     ccsw3
  60.         ldx     0,x
  61.         jmp     0,x
  62. ccsw3   inx
  63.         inx
  64.         inx
  65.         inx
  66.         bra     ccsw4
  67. ccsw2   pulx
  68.         jmp     2,x
  69. ccsw1   equ     *
  70.  
  71. *********************************************
  72. *
  73. *       ccmult --
  74. *               Multiplies D by X with result
  75. *       in D (signed 2's comp).
  76. *
  77. tmpd    equ  0
  78. tmpx    equ  2
  79. rslt    equ  4
  80. *
  81. ccmult  equ *
  82.  pshx
  83.  pshx
  84.  pshb
  85.  psha
  86.  tsx
  87.  ldaa  tmpx+1,x
  88.  mul
  89.  std  rslt,x
  90.  ldd  tmpd+1,x           ;get d-low and x-high
  91.  mul
  92.  addb  rslt,x
  93.  stab   rslt,x
  94.  ldaa   tmpd,x           ;get d-high and x-low
  95.  ldab   tmpx+1,x
  96.  mul
  97.  addb  rslt,x
  98.  stab   rslt,x           ;Will be valid 2's comp result
  99.  pulx                    ;peel stack down to result
  100.  pulx
  101.  pula                    ;return with result in D
  102.  pulb
  103.  rts
  104. *
  105. ********************************
  106. *
  107. *       ccor -- inclusive or
  108. *
  109. ccor    equ *
  110.  pshx
  111.  tsx
  112.  orab 1,x
  113.  oraa 0,x
  114.  pulx
  115.  rts
  116. ********************************
  117. *
  118. *       ccxor -- exclusive or
  119. *
  120. ccxor   equ *
  121.  pshx
  122.  tsx
  123.  eorb 1,x
  124.  eora 0,x
  125.  pulx
  126.  rts
  127. ********************************
  128. *
  129. *       ccand -- logical and
  130. *
  131. ccand   equ *
  132.  pshx
  133.  tsx
  134.  andb 1,x
  135.  anda 0,x
  136.  pulx
  137.  rts
  138. *
  139. **********************************
  140. *       ccasl -- shift left
  141. *
  142. ccasl   equ *
  143.  xgdx            ;Move value to shift from x to d
  144. asllpa  equ *
  145.  cpx    #0
  146.  ble     aslret
  147.    aslb
  148.    rola
  149.    dex
  150.  bra  asllpa
  151. aslret  equ *
  152.  rts
  153. *
  154. ***************************************
  155. *       cceq -- test X equal D
  156. *               1=true, 0=false
  157. *
  158. cceq    equ *
  159.  pshx
  160.  tsx
  161.  cpd  0,x
  162.  bne  noteq
  163.    ldd  #1
  164.    pulx
  165.    rts
  166. noteq   equ *
  167.    ldd  #0
  168.    pulx
  169.    rts
  170. *
  171. ***************************************
  172. *       ccne -- test X not equal D
  173. *               1=true, 0=false
  174. *
  175. ccne    equ *
  176.  pshx
  177.  tsx
  178.  cpd  0,x
  179.  beq  notne
  180.    ldd  #1
  181.    pulx
  182.    rts
  183. notne   equ *
  184.    ldd  #0
  185.    pulx
  186.    rts
  187. *
  188. ********************************
  189. *       ccasr -- shift right
  190. *
  191. ccasr   equ *
  192.  xgdx           ;Move value to shift from x to d, count from d to x
  193. asrlpa  equ *
  194.  cpx  #0
  195.  ble   asret
  196.    asra
  197.    rorb
  198.    dex
  199.  bra  asrlpa
  200. asret   equ *
  201.  rts
  202. *
  203. *
  204. ***************************************
  205. *       cclt -- test X less than D
  206. *               1=true, 0=false
  207. *
  208. cclt    equ     *
  209.         pshx
  210.         tsx
  211.         cpd  0,x
  212.         pulx
  213.         ble  notlt
  214.           ldd  #1
  215.           rts
  216. notlt   equ     *
  217.           ldd  #0
  218.           rts
  219. *
  220. ***************************************
  221. *       ccle -- test X less or equal D
  222. *               1=true, 0=false
  223. *
  224. ccle    equ     *
  225.         pshx
  226.         tsx
  227.         cpd  0,x
  228.         pulx
  229.         blt  notle
  230.           ldd  #1
  231.           rts
  232. notle   equ *
  233.           ldd  #0
  234.           rts
  235. *
  236. ***************************************
  237. *       ccgt -- test X greater than D
  238. *               1=true, 0=false
  239. *
  240. ccgt    equ *
  241.         pshx
  242.         tsx
  243.         cpd  0,x
  244.         pulx
  245.         bge  notgt
  246.           ldd  #1
  247.           rts
  248. notgt   equ *
  249.           ldd  #0
  250.           rts
  251. *
  252. ***************************************
  253. *       ccge -- test X greater or equal D
  254. *               1=true, 0=false
  255. *
  256. ccge    equ *
  257.         pshx
  258.         tsx
  259.         cpd  0,x
  260.         pulx
  261.         bgt  notge
  262.           ldd  #1
  263.           rts
  264. notge   equ *
  265.           ldd  #0
  266.           rts
  267. *
  268. ***************************************
  269. *       ccult -- test X less than(unsigned)  D
  270. *               1=true, 0=false
  271. *
  272. ccult   equ *
  273.         pshx
  274.         tsx
  275.         cpd  0,x
  276.         pulx
  277.         bls  notult
  278.           ldd  #1
  279.           rts
  280. notult  equ *
  281.           ldd  #0
  282.           rts
  283. *
  284. ***************************************
  285. *       ccule -- test X less than or equal(unsigned)  D
  286. *               1=true, 0=false
  287. *
  288. ccule   equ *
  289.         pshx
  290.         tsx
  291.         cpd  0,x
  292.         pulx
  293.         blo  notule
  294.           ldd  #1
  295.           rts
  296. notule  equ *
  297.           ldd  #0
  298.           rts
  299. *
  300. ***************************************
  301. *       ccugt -- test X greater(unsigned) D
  302. *               1=true, 0=false
  303. *
  304. ccugt   equ *
  305.         pshx
  306.         tsx
  307.         cpd  0,x
  308.         pulx
  309.         beq  notugt
  310.         bhs  notugt
  311.           ldd  #1
  312.           rts
  313. notugt  equ *
  314.           ldd  #0
  315.           rts
  316. *
  317. ***************************************
  318. *       ccuge -- test X greater or equal D
  319. *               (unsigned)
  320. *               1=true, 0=false
  321. *
  322. ccuge   equ *
  323.         pshx
  324.         tsx
  325.         cpd  0,x
  326.         pulx
  327.         bhi  notuge
  328.           ldd  #1
  329.           rts
  330. notuge  equ *
  331.           ldd  #0
  332.           rts
  333.  
  334.